//
//  ViewController.m
//  外设端
//
//  Created by apple on 16/4/6.
//  Copyright © 2016年 SherrySorftware. All rights reserved.
//

#import "ViewController.h"
#import "CVBleObj.h"
@interface ViewController ()<bleObjDelegate>
{
    CVBleObj *bleObj;
    __weak IBOutlet UILabel *lab_state;
    __weak IBOutlet UITextView *tv;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    bleObj = [CVBleObj shareDelegate];
    bleObj.delegate = self;
}

//外设状态更新
- (void)peripheralManagerDidUpdateState:(PMSTATE)state {
    switch (state) {
        case 0:
            NSLog(@"powered on");
            [lab_state setText:@"powered on"];
            break;
        case 1:
            NSLog(@"powered off");
            [lab_state setText:@"powered off"];
            break;
        default:
            break;
    }
}

- (void)logDidUpdata:(NSString *)string {
    NSLog(@"%@",string);
    tv.text = string;
}

- (IBAction)send:(id)sender {
    [bleObj sendDataWithString:@"喂，妖妖灵吗？" characteristic:0];
}

- (IBAction)send1:(id)sender {
    [bleObj sendDataWithString:@"喂，肯德基吗？我要一份麦当劳" characteristic:1];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
